package view.mediator.weapon.great_sword
{
	import flash.system.System;
	
	import model.weapon.WeaponModel;
	
	import org.robotlegs.mvcs.StarlingMediator;
	
	import view.component.weapon.great_sword.GreatSwordView;
	import view.event.weapon.great_sword.GreatSwordViewEvent;
	
	
	/**
	 * GreatSwordView界面中介
	 * @author £iang
	 * 
	 */	
	public class GreatSwordViewMediator extends StarlingMediator
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** GreatSwordView界面 */
		[Inject]
		public var greatSwordView:GreatSwordView;
		/** weaponModel */
		[Inject]
		public var weaponModel:WeaponModel;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 注册函数 
		 * 
		 */		
		override public function onRegister():void
		{
			greatSwordView.otherView.setText( weaponModel.weaponOtherInfoData["great_sword"] );
			addContextListener( GreatSwordViewEvent.CHANGE_PAGE, changePageHandler );
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		/**
		 * 处理请求滚动条容器翻页时派发的消息 
		 * @param event 请求滚动条容器翻页时派发的消息 
		 * 
		 */		
		protected function changePageHandler( event:GreatSwordViewEvent ):void
		{
			greatSwordView.changeSCPageIndex( event.newPage );
		}
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 移除函数 
		 * 
		 */		
		override public function onRemove():void
		{
			removeContextListener( GreatSwordViewEvent.CHANGE_PAGE, changePageHandler );
			greatSwordView.mainSC.removeChild( greatSwordView.listView, true );
			greatSwordView.listView = null;
			greatSwordView.mainSC.removeChild( greatSwordView.detailView, true );
			greatSwordView.detailView = null;
			greatSwordView.mainSC.removeChild( greatSwordView.searchView, true );
			greatSwordView.searchView = null;
			greatSwordView.mainSC.removeChild( greatSwordView.motionView, true );
			greatSwordView.motionView = null;
			System.gc();
			super.onRemove();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function GreatSwordViewMediator()
		{
			super();
		}
	}
}